package test;

import exthread.MyThread;


/**
 * 停止线程——异常法
 */
public class Run {

	public static void main(String[] args) {
		try {
			MyThread thread = new MyThread();
			thread.start();
			Thread.sleep(2000);
			thread.interrupt();
		} catch (InterruptedException e) {
			System.out.println("main catch");
			e.printStackTrace();
		}
		System.out.println("end!");
	}

	/**
	 * 输出结果：
	 * i=240621
	   i=240622
	   end!
	   已经是停止状态了!我要退出了!
	   进MyThread.java类run方法中的catch了
	   java.lang.InterruptedException
	   at exthread.MyThread.run(MyThread.java:11)
	 *
	 *
	 */

}
